<?php

// no direct access
defined('_JEXEC') or die('Restricted access');

// import application controller
jimport('joomla.application.component.controller');

class SyncrControllerAbout extends JController
{
	public function __construct($config = array()) {
		parent::__construct($config);
	}
	
	public function display()
	{
		// set view if not specified
		if (!$view = JRequest::getVar('view')) {
			JRequest::setVar('view', 'about');
		}
		
		// call parent behavior
		parent::display();
	}
	
	public function getSiteDetails()
	{	
		$db =& JFactory::getDBO();
	
		$id = JRequest::getInt('siteId', 0);
		
		$query = 'SELECT id'
			   .', url'
			   .', logo'
			   .', apikey'
			   .', image'
			   .' FROM #__syncr_sites'
			   .' WHERE id = '.$id
			   ;				   
		$db->setQuery($query);

		echo json_encode($db->loadObject());
		
		return;
	}
	
	public function keyGenerator()
	{
		$code = md5(uniqid(rand(), true));
		echo substr($code, 0, 36);
	}
}